import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * @Description
 */

public class Game {

    public static final String[] SUITS = {"♣","♠","♦","♥"};

    public ArrayList<Card> crateCards(){
        ArrayList<Card> cardsList = new ArrayList<>();//容器
        for (int i = 0; i < SUITS.length; i++) {
            for (int j = 0; j < 13; j++) {
                Card card = new Card(SUITS[i],j);
                cardsList.add(card);
            }
        }
        return cardsList;
    }
    public void shuffle(ArrayList<Card> cards){
        Random random = new Random();
        for (int i = cards.size()-1; i >0; i--) {
            int randIndex = random.nextInt(i);
            swap(cards,i,randIndex);
        }

}
    private void swap(ArrayList<Card> cardsList,int i,int j ){
        Card tmp = cardsList.get(i);
        cardsList.set(i,cardsList.get(j));
        cardsList.set(j,tmp);
    }
    public ArrayList<ArrayList<Card>> play(ArrayList<Card> cardsList ){
        ArrayList<ArrayList<Card>> hand = new ArrayList<>();

        ArrayList<Card> hand0 = new ArrayList<>();
        ArrayList<Card> hand1 = new ArrayList<>();
        ArrayList<Card> hand2 = new ArrayList<>();
        hand.add(hand0);
        hand.add(hand1);
        hand.add(hand2);

        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 3; j++) {
                Card card = cardsList.remove(0);
                hand.get(j).add(card);
            }
            
        }
        return hand;
    }
}
